const { regeneratorRuntime } = global

Page(global.connect(
  state => ({
    ...state.globalReducer
  }),
  dispatch => ({
    //   async setPageImageSelect(data) {
    //     return await dispatch(global.globalReducer.setPageImageSelect(data))
    //   },
    async pageImageSelectSubmit(data) {
      return await dispatch(global.globalReducer.pageImageSelectSubmit(data))
    }
  })
)({
  data: {
    tplImageData: []
  },
  onLoad(e) {
    console.log('onUnload', e)
    const { imageData } = this.data
    const copy = JSON.parse(JSON.stringify(imageData))
    this.setData({ tplImageData: copy })
  },
  onUnload(e) {
    console.log('onUnload', e)
  },
  handleSelect(e) {
    const { index } = e.currentTarget.dataset
    console.log('handleSelect', index)

    const { multiple, tplImageData } = this.data

    if (!multiple) {
      tplImageData.map(i => i.checked = false)
    }
    tplImageData[index].checked = !tplImageData[index].checked
    this.setData({ tplImageData })

    // this.setPageImageSelect({
    //   multiple: false,
    //   index,
    // })
  },
  handleConfirm(e) {
    console.log('handleConfirm', e)
    const { tplImageData } = this.data
    this.pageImageSelectSubmit({
      imageData: tplImageData
    })
    wx.navigateBack()
  },
  handleLicon1Tap(e) {
    wx.navigateBack()
  }
}))